// 首先导入Sequelize模块
const { Sequelize } = require('sequelize');

// 1. 先创建Sequelize实例
const sequelize = new Sequelize('mh', 'root', '123456', {
  host: 'localhost',
  dialect: 'mysql',
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
});

// 2. 然后再导入并初始化模型
const Follow = require('./follow')(sequelize, Sequelize.DataTypes);

// 测试数据库连接
sequelize.authenticate()
  .then(() => console.log('数据库连接成功'))
  .catch(err => console.error('数据库连接失败:', err));

module.exports = {
  sequelize,
  Follow
};